#ifndef __TCTP_H
#define __TCTP_H	

#include <stdlib.h>
#include <string.h>  

#define PACKET_HEAD           0xA5  //定义报文起始    
#define PACKET_DATA           0x03  //定义报文长度数据

#define HEAD_LEN              0x01    //定义报文开头长度
#define PACKET_LEN            0x01  //定义报文数据长度
#define DATASIZE_LEN          0x01    //定义数据大小长度          
#define CRC_LEN               0x01    //定义CRC校验长度
#define PAG_LEN               0x02   //定义数据帧长度

    
#define TCTP_HEAD_LEN         HEAD_LEN+DATASIZE_LEN  //定义报文头长度    

#define HOST_ENDIAN           0x00      //定义主机字节序
#define NET_ENDIAN            0x01      //定义网络字节序

    
//TCTP功能码枚举
typedef enum
{
    //空气温度
	REQ_ARTEMP = 0x01, 
    
    //电机控制
	REQ_MOTOR_CONTRL,   

    //电机查询
	REQ_MOTOR_STUTE,    
    
    //加热控制
	REQ_HEAT_CONTRL,    
    
    //加热查询
	REQ_HEAT_STUTE,  
    
    //电机转速查询
    REQ_MOTOR_SPEED,
    
    //设置工作模式
    REQ_WORK_MODE
  
}TCTP_CODE_T;      
    
    
//传送代理结构
typedef struct
{
    unsigned char *Buffer;        //数据包地址
    unsigned short BufferSize;    //数据包大小
    unsigned short BufferOffset;  //数据包偏移
} TCTP_Broker_T;   

//传送代理结构


    
void Add_CRC(unsigned char *puchMsg , unsigned char usDataLen);
unsigned char Calc_CRC(unsigned char *puchMsg , unsigned char usDataLen);
unsigned char TCTP_PackWithOutPacketVerify(unsigned char CMD,TCTP_Broker_T *TctpBroker);
unsigned char TCTP_Pack(unsigned char CMD,TCTP_Broker_T *TctpBroker);
unsigned char TCTP_Load_Data(unsigned char *Data,unsigned char DataSize,TCTP_Broker_T *DataBroker,unsigned char Endian);
unsigned char TCTP_PacketDelete(TCTP_Broker_T *DataBroker);

#endif  
	 



